import { Body, Controller, Post ,UseFilters} from '@nestjs/common';
import { Public } from './pubulic.decorator';
import { AuthService } from './auth.service';
import { HttpExceptionFilter } from '../../exception/http-exception.filter';
import { success,errorReq,warpperResponse } from 'src/utils';
@Controller('auth')
export class AuthController {
  constructor(private readonly AuthService: AuthService) {}
  @Public()
  @UseFilters(new HttpExceptionFilter())
  @Post('login')
 async login(@Body() loginDto: { username: string; password: string }) {
    try {
      const res=await this.AuthService.login(loginDto)
      return success(res,'登录成功') ;
    } catch (error) {
      return errorReq('登录失败') ;
    }
   
    
   
  }
}
